﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simulation
{
	class PriorityQueue<T> : IEnumerable<T>
	{
		private List<T> _innerQueue;

		public PriorityQueue()
		{
			_innerQueue = new List<T>();
		}

		public IEnumerator<T> GetEnumerator()
		{
			return _innerQueue.GetEnumerator();
		}

		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
		{
			return (IEnumerator<T>)GetEnumerator();
		}

		public void Enqueue(T obj)
		{
			_innerQueue.Add(obj);
			_innerQueue.Sort();
		}

		public T Dequeue()
		{
			T temp = _innerQueue[0];
			
			//move all the shit down
			for (int i = 0; i < _innerQueue.Count()-1; i++)
				_innerQueue[i] = _innerQueue[i + 1];

			//remove the last one
			_innerQueue.RemoveAt(_innerQueue.Count() - 1);

			return temp;
		}

	}
}
